package com.sentiment.database.bean;

import java.util.Date;
import java.util.List;

import org.bson.BsonDocument;
import org.bson.BsonDocumentWrapper;
import org.bson.Document;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.types.ObjectId;

import com.sentiment.nlpalgo.bean.Double2;
import com.sentiment.nlpalgo.bean.Keywords;

@SuppressWarnings("serial")
public class ForumInfo extends Document {

	public static final String dbName = "SentimentDB";
	public static final String collection = "ForumInfo";
	    // private ObjectId _id;
		// 爬取时间
		// private Date date;
		// 关键词id
		// private ObjectId keyword_id;
		// 标题
		// private String title;
		// 正文
		// private List<String> text;
		// 地址
		// private String url;
		// 发布作者
		// private String publisher;
		// 来源
	    // private String from;
		// 发布时间
		// private Date releaseTime;
		// 点击次数
		// private Integer clicktimes;
		// 回复数
		// private Integer comment;
	
		// 回复数据
        //private List<String> comTexts; 
	    
		// 正文舆情分析
		// private List<Double2> sentiment;
		// 关键词分析
		// private List<Keywords> keywords;
	public ForumInfo() {
		// TODO Auto-generated constructor stub
	}
	public void setUpdate(String method, CrawlNews n) {
		append(method, n);
	}

	public ObjectId get_id() {
		return getObjectId("_id");
	}

	public void set_id(ObjectId _id) {
		append("_id", _id);
	}

	public Date getDate() {
		return getDate("date");
	}

	public void setDate(Date date) {
		append("date", date);
	}

	public ObjectId getKeyword_id() {
		return getObjectId("keyword_id");
	}

	public void setKeyword_id(ObjectId keyword_id) {
		append("keyword_id", keyword_id);
	}

	public String getTitle() {
		return getString("title");
	}

	public void setTitle(String title) {
		append("title", title);
	}

	@SuppressWarnings("unchecked")
	public List<String> getText() {
		return (List<String>) get("text");
	}

	public void setText(List<String> text) {
		append("text", text);
	}

	public String getUrl() {
		return getString("url");
	}

	public void setUrl(String url) {
		append("url", url);
	}
	
	public String getPublisher() {
		return getString("publisher");
	}

	public void setPublisher(String publisher) {
		append("publisher", publisher);
	}

	
	public void setFrom(String from){
		append("from",from);
	}
	public String getFrom(){
		return getString("from");
	}
	public Date getReleaseTime() {
		return getDate("releaseTime");
	}

	
	
	public void setReleaseTime(Date releaseTime) {
		append("releaseTime", releaseTime);
	}

	public Integer getClicktimes() {
		return getInteger("clicktimes");
	}

	public void setClicktimes(Integer clicktimes) {
		append("clicktimes", clicktimes);
	}

	public Integer getComment() {
		return getInteger("comment");
	}

	public void setComment(Integer comment) {
		append("comment", comment);
	}

	
	
	@SuppressWarnings("unchecked")
	public List<String> getComTexts() {
		return (List<String>) get("comTexts");
	}

	public void setComTexts(List<String> comTexts) {
		append("comTexts", comTexts);
	}
	
	
	@SuppressWarnings("unchecked")
	public List<Double2> getSentiment() {
		return (List<Double2>) get("sentiment");
	}

	public void setSentiment(List<Double2> sentiment) {
		append("sentiment", sentiment);
	}

	@SuppressWarnings("unchecked")
	public List<Keywords> getKeywords() {
		return (List<Keywords>) get("keywords");
	}

	public void setKeywords(List<Keywords> keywords) {
		append("keywords", keywords);
	}

	public ForumInfo(ObjectId _id, Date date, ObjectId keyword_id, String title, List<String> text, String url,
			String publisher, String from,Date releaseTime, Integer clicktimes, Integer comment, List<String> comTexts,
			List<Double2> sentiment,List<Keywords> keywords) {
		append("_id", _id);
		append("date", date);
		append("keyword_id", keyword_id);
		append("title", title);
		append("text", text);
		append("url", url);
		append("publisher", publisher);
		append("from",from);
		append("releaseTime", releaseTime);
		append("clicktimes", clicktimes);
		append("comment", comment);
		append("comTexts",comTexts);
		append("sentiment", sentiment);
		append("keywords", keywords);
	}

	@Override
	public <TDocument> BsonDocument toBsonDocument(Class<TDocument> documentClass, CodecRegistry codecRegistry) {
		// TODO Auto-generated method stub
		return new BsonDocumentWrapper<ForumInfo>(this, codecRegistry.get(ForumInfo.class));
	}
	
}
